//
//  Copyright: (C) 2006-2008 by Kandalu Software 
//  London
//  info@kandalu.net
//

#import "StartingPointsWindowController.h"

//#import "Globals.h"


@implementation StartingPointsWindowController

#pragma mark Initializer

- (id)init
{
  self = [super initWithWindowNibName:@"StartingPointsWindow"];
  return self;
}

#pragma mark IB Actions for Starting Points Panel

- (IBAction)showStartingPointsWindow:(id)sender
{
  [self showWindow:sender];
}



- (IBAction)startingPointsCancelled:(id)sender
{
  [[self window] orderOut:self];
}

- (IBAction)startingPointsOpen:(id)sender
{
  NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
  int oldDocumentCount = [[documentController documents] count];

  [documentController openDocument:sender];

  if ([[documentController documents] count] > oldDocumentCount) // if something was opened ...
    [[self window] orderOut:self]; // ...then hide the starting points window
}

#pragma mark Internal

- (void)releaseAndGetIntoVariable:(NSWindowController **)var
  instanceOfWindowControllerClass:(Class)class
                    andShowWindow:(id)sender
{
  if (*var)
  {
    [*var release];
    *var = nil;
  }

  *var = [[class alloc] init];

  [*var showWindow:sender];
  [[self window] miniaturize:sender];  
}

@end
